package com.kuangshenJVM.chapter03;

public class test03 {
    public static void main(String[] args) {
        System.out.println("---------创建的对象不同----------------");
        User user01 = new User();
        System.out.println("user01 ==》" + user01);
        User user02 = new User();
        System.out.println("user02 ==》" + user02);
        User user03 = new User();
        System.out.println("user03 ==》" + user03);

        System.out.println("-------------类和类加载器都是一样的-----------------");
        Class aClass01 = user01.getClass();
        System.out.println("aClass01 ==》" + aClass01);
        ClassLoader classLoader01 = aClass01.getClassLoader();
        System.out.println("classLoader01 ==>" + classLoader01);

        Class aClass02 = user02.getClass();
        System.out.println("aClass02 ==》" + aClass02);
        ClassLoader classLoader02 = aClass02.getClassLoader();
        System.out.println("classLoader02 ==>" + classLoader02);

        Class aClass03 = user03.getClass();
        System.out.println("aClass03 ==》" + aClass03);
        ClassLoader classLoader03 = aClass03.getClassLoader();
        System.out.println("classLoader03 ==>" + classLoader03);

        System.out.println("----------------------------");
        System.out.println("扩展类加载器" + classLoader01.getParent());

        System.out.println("引导类加载器" + classLoader01.getParent().getParent());


    }
}

class User{
    private String name;
    private Integer age;

    public User() {
    }

    public User(String name, Integer age) {
        this.name = name;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    @Override
    public int hashCode() {
        return super.hashCode();
    }

    @Override
    public boolean equals(Object obj) {
        return super.equals(obj);
    }

    @Override
    protected Object clone() throws CloneNotSupportedException {
        return super.clone();
    }

    @Override
    public String toString() {
        return super.toString();
    }

    @Override
    protected void finalize() throws Throwable {
        super.finalize();
    }
}

